<?php
declare (strict_types=1);

namespace app\common\model;

class Area extends Base
{
    protected $name = 'area';


    public static function getArea($parent_code = 100000, $level = 1)
    {

        switch ($level) {
            case 1:
                $filed = 'province as title';
                break;
            case 2:
                $filed = 'city as title';
                break;
            case 3:
                $filed = 'district as title';
                break;
            case 4:
                $filed = 'town as title';
                break;
        }

        return parent::where(['parent_code' => $parent_code, 'level' => $level])
            ->field('code,' . $filed)->select();
    }
}
